﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace calculator_winForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
          
        }
        public void My_Conbobox()
        {
            comboBox1.Items.Add("+");
            comboBox1.Items.Add("-");
            comboBox1.Items.Add("*");
            comboBox1.Items.Add("/");
        }
        private void enter_Click(object sender, EventArgs e)
        {
            double i=1.0, j = 1.0;
            string ans;
            ansLabel.Text = "";
            try { 
                i = double.Parse(firstNum.Text);
                Console.WriteLine(i);
            }
            catch
            {
                ans = "The first input is wrong, please check\n";
                ansLabel.Text += ans;
                
            }
            try
            {
                j = double.Parse(secondNum.Text);
            }
            catch
            {
                ans = "The second input is wrong, please check\n";
                ansLabel.Text += ans;
            }
            double ansNum;

            switch (comboBox1.SelectedItem.ToString())
            {
                case "+":
                    ansNum = i + j;
                    break;
                case "-":
                    ansNum = i - j;
                    break;
                case "*":
                    ansNum = i * j;
                    break;
                case "/":
                    ansNum = i / j;
                    break;
                
                default:
                    ans = "Do not support this type of calculation\n";
                    ansLabel.Text += ans;
                    return;

            }
            ans = ansNum.ToString();
            ansLabel.Text = ans;
            return;

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            My_Conbobox();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
